import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import vueaxios from 'vue-axios'
import vuecookie from 'vue-cookie'
import env from './evn'
import store from './store'
import "element-ui/lib/theme-chalk/index.css";
import elementui from 'element-ui'

Vue.use(elementui);
//根据前端的跨域方式做调整
axios.defaults.baseURL = 'http://localhost:3000/';
axios.defaults.timeout = 8000;

// 接口错误拦截
axios.interceptors.response.use(function (response) {
  let res = response.data;//获取结果
  if (res.status == 200) {//成功
    return res.data;
  }
  else if (res.status == 10) {//未登录
    if(location.href!='index'){
      window.location.href='/login';
    }
  }
  else {
    Promise.reject(res);
  }
});

Vue.use(vueaxios, axios);
Vue.use(vuecookie);
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: function (h) { return h(App) }
}).$mount('#app')
